<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<% String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<jsp:include page="../../import.jsp" flush="true" />

<style>

</style>

</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<form id="ligerForm">
				<div class="fieldset1 tabel_col clearFix">
					<div class="caption">
						<span class="title">借阅申请</span>
					</div>
					<div class="fieldBox col_50">
						<div class="label">合同号</div>
						<div class="field">
							${arcBorrowMainVO.contractNo}
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">交接单名称</div>
						<div class="field">
							${arcBorrowMainVO.arcReceiptName}
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">省公司档案袋编号</div>
						<div class="field">${arcBorrowMainVO.portfolioNumberProvince}
						</div>
					</div>
					<div class="fieldBox col_50">
						<div class="label">总部档案袋编号</div>
						<div class="field">${arcBorrowMainVO.portfolioNumber}
						</div>
					</div>
					
					<div class="caption">
						<span class="title">合同资料、承租人资料、担保人资料 ${arcBorrowMainVO.cstNm}  ${arcBorrowMainVO.contractNo}</span>
					</div>
					<div class="fieldBox col_100">
						<div style="width: 98%; margin-left: 1%;">
							<div id="gridContract" class="sq-grid"></div>
						</div>
					</div>
					
					<div class="caption">
						<span class="title">权证资料</span>
					</div>
					<c:forEach items="${arcBorrowDetailVOList}" var="arcBorrowDetailVO">
						<div class="fieldBox col_100">
						${arcBorrowDetailVO.paylistCode}
						车架号:${arcBorrowDetailVO.vin}
							<div style="width: 98%; margin-left: 1%;">
								<div id="gridPay${arcBorrowDetailVO.paylistCode}" class="sq-grid"></div>
							</div>
						</div>
					</c:forEach>
					
					<div class="caption">
						<span class="title">申请人邮寄信息</span>
					</div>
					
					<div class="fieldBox col_100">
						<div style="width: 98%; margin-left: 1%;">
							<div id="gridProposerPostInfo" class="sq-grid"></div>
						</div>
					</div>
					
					<div class="caption">
						<span class="title">邮寄信息</span>
					</div>
					<div class="fieldBox col_100">
						<div style="width: 98%; margin-left: 1%;">
							<div id="gridPostInfo" class="sq-grid"></div>
						</div>
					</div>
					
					<div class="caption">
						<span class="title">上传附件信息</span>
					</div>
					<div class="fieldBox col_100">
					
						<!-- 附件列表展示和上传 -->
					   <c:if test="${from=='contractManager'}">
							<jsp:include page="sysUlFileRecList.jsp" flush="true" >
					            <jsp:param name="pkId" value="${arcBorrowMainVO.id}"/>
					            <jsp:param name="tabNm" value="ARC_BORROW_MAIN"/>
					            <jsp:param name="canDel" value="true"/>
					        </jsp:include>
				        	<jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp" flush="true" >
								<jsp:param name="filePath" value="warrant/"/>
							</jsp:include>
				        </c:if>
				        <!-- 附件列表展示 -->
				        <c:if test="${from!='contractManager'}">
							<jsp:include page="sysUlFileRecList.jsp" flush="true" >
					            <jsp:param name="pkId" value="${arcBorrowMainVO.id}"/>
					            <jsp:param name="tabNm" value="ARC_BORROW_MAIN"/>
					        </jsp:include>
				        </c:if>
					</div>
					
					<c:if test="${from=='postProvince' || from=='postZong'}"> 
						<div class="caption">
							<span class="title">
								<c:if test="${from=='postProvince'}">省公司</c:if>
								<c:if test="${from=='postZong'}">总公司</c:if>
								邮寄信息
							</span>
						</div>
						<div class="fieldBox col_50">
							<div class="label">工号/姓名</div>
							<div class="field">
								<input id="jobNum"  name="jobNum"  type="text"   class="ui-textbox"  ligerui="width: 160" />
									<a class="sq-button-hasicon" href="javascript:getSysUsr('jobNum','idCard','recipient','mobile');"><i class="sqBtnIco_4"></i>查找收件人</a>
							</div>
						</div>
						<div class="fieldBox col_50">
						</div>
						
						<div class="fieldBox col_50">
							<div class="label">收件人（工号）</div>
							<div class="field">
								<input id="idCard"  name="idCard"  type="text"   class="ui-textbox"  ligerui="width: 160"  disabled="disabled"  
								value="${arcPostInfoVO.idCard}"/>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">收件人（姓名）</div>
							<div class="field">
								<input id="recipient"  name="recipient"  type="text"   class="ui-textbox"  ligerui="width: 160"   disabled="disabled"  
								value="${arcPostInfoVO.recipient}"/>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">联系电话</div>
							<div class="field">
								<input id="mobile"  name="mobile"  type="text"   class="ui-textbox"  ligerui="width: 160" 
									value="${arcPostInfoVO.mobile}"  validate="{required:true,mobile:true}"/>
							</div>
						</div>
						<div class="fieldBox col_50">
								<div class="label">接收方式</div>
								<div class="field">
									<select id="sendType"  name="sendType"  ligerui="width: 160">
											<option value="">请选择</option>
											<c:forEach items="${sendTypeList}" var="item">
												<option value="${item.key}" <c:if test="${item.key == arcPostInfoVO.sendType}">selected="selected"</c:if> >${item.value}</option>
											</c:forEach>
										</select>
								</div>
							</div>
							
						<div id="emailInfo" style="display: none;">
							<div class="fieldBox col_50">
								<div class="label">快递公司</div>
								<div class="field">
									<select id="sendCompany"  name="sendCompany"  ligerui="width: 160" >
											<option value="">请选择</option>
											<c:forEach items="${sendCompanyList}" var="item">
												<option value="${item.key}"    <c:if test="${item.key == arcPostInfoVO.sendCompany}">selected="selected"</c:if> >${item.value}</option>
											</c:forEach>
										</select>
								</div>
							</div>
							<div class="fieldBox col_50">
								<div class="label">快递单号</div>
								<div class="field">
									<input id="sendNum"  name="sendNum"  type="text"   class="ui-textbox"  ligerui="width: 160" 
										value="${arcPostInfoVO.sendNum}"   />
								</div>
							</div>
							<div class="fieldBox col_100">
								<div class="label">邮寄地址</div>
								<div class="field">
									<textarea id="sendAddr"  name="sendAddr" rows="3" class="l-textarea" 
										style="width:100%">${arcPostInfoVO.sendAddr}</textarea>
								</div>
							</div>
							</div>
					</div>
					
					<div class="btnsBox">
							<span id="saveBtn" class="sq-button sq-button-round" onclick="save();">保存</span>
					</div>
				</c:if>
			</form>
				
				
				<!-- 借阅人归还--含省公司 -->
				<c:if test="${arcAppBussTypeProvince == 4}"> 
				<form id="ligerFormProvince">
						<div class="caption">
							<span class="title">
								省公司邮寄信息【归还】
							</span>
						</div>
						<div class="fieldBox col_50">
							<div class="label">工号/姓名</div>
							<div class="field">
								<input id="jobNumProvince"  name="jobNum"  type="text"   class="ui-textbox"  ligerui="width: 160" />
									<a class="sq-button-hasicon" href="javascript:getSysUsr('jobNumProvince','idCardProvince','recipientProvince','mobileProvince');"><i class="sqBtnIco_4"></i>查找收件人</a>
							</div>
						</div>
						<div class="fieldBox col_50">
						</div>
						<div class="fieldBox col_50">
							<div class="label">收件人（工号）</div>
							<div class="field">
								<input id="idCardProvince"  name="idCard"  type="text"   class="ui-textbox"  ligerui="width: 160"   readonly="readonly"  
								value="${arcPostInfoVOProvince.idCard}"/>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">收件人（姓名）</div>
							<div class="field">
								<input id="recipientProvince"  name="recipient"  type="text"   class="ui-textbox"  ligerui="width: 160"   readonly="readonly"  
								value="${arcPostInfoVOProvince.recipient}"/>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">联系电话</div>
							<div class="field">
								<input id="mobileProvince"  name="mobile"  type="text"   class="ui-textbox"  ligerui="width: 160" 
									value="${arcPostInfoVOProvince.mobile}" />
							</div>
						</div>
						
						<div class="fieldBox col_50">
							<div class="label">接收方式</div>
							<div class="field">
								<select id="sendTypeProvince"  name="sendType"  ligerui="width: 160">
										<option value="">请选择</option>
										<c:forEach items="${sendTypeList}" var="item">
											<option value="${item.key}" <c:if test="${item.key == arcPostInfoVOProvince.sendType}">selected="selected"</c:if> >${item.value}</option>
										</c:forEach>
									</select>
							</div>
						</div>
						
						<div id="emailInfoProvince" style="display: none;">
							<div class="fieldBox col_50">
								<div class="label">快递公司</div>
								<div class="field">
									<select id="sendCompanyProvince"  name="sendCompany"  ligerui="width: 160" >
											<option value="">请选择</option>
											<c:forEach items="${sendCompanyList}" var="item">
												<option value="${item.key}"    <c:if test="${item.key == arcPostInfoVOProvince.sendCompany}">selected="selected"</c:if> >${item.value}</option>
											</c:forEach>
										</select>
								</div>
							</div>
							<div class="fieldBox col_50">
								<div class="label">快递单号</div>
								<div class="field">
									<input id="sendNumProvince"  name="sendNum"  type="text"   class="ui-textbox"  ligerui="width: 160" 
										value="${arcPostInfoVOProvince.sendNum}"   />
								</div>
							</div>
							<div class="fieldBox col_100">
								<div class="label">邮寄地址</div>
								<div class="field">
									<textarea id="sendAddrProvince"  name="sendAddr" rows="3" class="l-textarea" 
										style="width:100%">${arcPostInfoVOProvince.sendAddr}</textarea>
								</div>
							</div>
							</div>
						<c:if test="${arcAppBussTypeProvince == 4}"> 
							<div class="btnsBox">
									<span id="saveBtnReturn" class="sq-button sq-button-round" onclick="saveReturn('${arcAppBussTypeProvince}');">保存邮寄信息(省公司)</span>
							</div>
						</c:if>
						</form>
				</c:if>
				
				<!-- 借阅人归还--含总公司 -->
				<c:if test="${arcAppBussTypeZong == 5}"> 
					<form id="ligerFormZong">
						<div class="caption">
							<span class="title">
								总公司邮寄信息【归还】
							</span>
						</div>
						<div class="fieldBox col_50">
							<div class="label">工号/姓名</div>
							<div class="field">
								<input id="jobNumZong"  name="jobNum"  type="text"   class="ui-textbox"  ligerui="width: 160" />
									<a class="sq-button-hasicon" href="javascript:getSysUsr('jobNumZong','idCardZong','recipientZong','mobileZong');"><i class="sqBtnIco_4"></i>查找收件人</a>
							</div>
						</div>
						<div class="fieldBox col_50">
						</div>
						<div class="fieldBox col_50">
							<div class="label">收件人（工号）</div>
							<div class="field">
								<input id="idCardZong"  name="idCard"  type="text"   class="ui-textbox"  ligerui="width: 160"  readonly="readonly" 
								value="${arcPostInfoVOZong.idCard}"/>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">收件人（姓名）</div>
							<div class="field">
								<input id="recipientZong"  name="recipient"  type="text"   class="ui-textbox"  ligerui="width: 160"   readonly="readonly" 
								value="${arcPostInfoVOZong.recipient}"/>
							</div>
						</div>
						<div class="fieldBox col_50">
							<div class="label">联系电话</div>
							<div class="field">
								<input id="mobileZong"  name="mobile"  type="text"   class="ui-textbox"  ligerui="width: 160" 
									value="${arcPostInfoVOZong.mobile}" />
							</div>
						</div>
						
						<div class="fieldBox col_50">
							<div class="label">接收方式</div>
							<div class="field">
								<select id="sendTypeZong"  name="sendType"  ligerui="width: 160">
										<option value="">请选择</option>
										<c:forEach items="${sendTypeList}" var="item">
											<option value="${item.key}" <c:if test="${item.key == arcPostInfoVOZong.sendType}">selected="selected"</c:if> >${item.value}</option>
										</c:forEach>
									</select>
							</div>
						</div>
						
						<div id="emailInfoZong" style="display: none;">
							<div class="fieldBox col_50">
								<div class="label">快递公司</div>
								<div class="field">
									<select id="sendCompanyZong"  name="sendCompany"  ligerui="width: 160" >
											<option value="">请选择</option>
											<c:forEach items="${sendCompanyList}" var="item">
												<option value="${item.key}"    <c:if test="${item.key == arcPostInfoVOZong.sendCompany}">selected="selected"</c:if> >${item.value}</option>
											</c:forEach>
										</select>
								</div>
							</div>
							<div class="fieldBox col_50">
								<div class="label">快递单号</div>
								<div class="field">
									<input id="sendNumZong"  name="sendNum"  type="text"   class="ui-textbox"  ligerui="width: 160" 
										value="${arcPostInfoVOZong.sendNum}"   />
								</div>
							</div>
							<div class="fieldBox col_100">
								<div class="label">邮寄地址</div>
								<div class="field">
									<textarea id="sendAddrZong"  name="sendAddr" rows="3" class="l-textarea" 
										style="width:100%">${arcPostInfoVOZong.sendAddr}</textarea>
								</div>
							</div>
						</div>
						
					</form>
				</c:if>
				<c:if test="${arcAppBussTypeZong == 5}"> 
					<div class="btnsBox">
							<span id="saveBtnReturn" class="sq-button sq-button-round" onclick="saveReturn('${arcAppBussTypeZong}');">保存邮寄信息(总公司)</span>
					</div>
				</c:if>
				
				
				
				
				
			
		</div>
	</div>
	<script type="text/javascript">
	     var  contractNo = "${arcBorrowMainVO.contractNo}";//合同号
	     
	     
		$(function() {
			$("#ligerForm").ligerForm({
		        validate : true
		    });
			//$("#ligerFormProvince").ligerForm();
			//$("#ligerFormZong").ligerForm();
			
			initGrid();//初始化数据：合同明细、支付表明细、邮寄信息

			$("#borrowUse").ligerComboBox({
				valueField: 'key',
				textField: 'value',
				width:150
			});
			
			$("#borrowType").change(function(){
				setBorrowUse(this);
			});
			
			//接收方式
			$("#sendType").change(function(){
				setSendType();
			});
			
			$("#sendTypeProvince").change(function(){
				if(this.value!= "" && this.value == 0) {//邮寄
					$("#emailInfoProvince").show();
				}else {
					$("#emailInfoProvince").hide();
				}
			});
			
			$("#sendTypeZong").change(function(){
				if(this.value!= "" && this.value == 0) {//邮寄
					$("#emailInfoZong").show();
				}else {
					$("#emailInfoZong").hide();
				}
			});
			
			setSendType();
			
	    });
		
		//接收方式
		function setSendType(){
			if($("#sendType").val() == 0) {//邮寄
				$("#emailInfo").show();
			}else {
				$("#emailInfo").hide();
			}
		}
		
		var arcPostInfoId = "${arcPostInfoVO.id}";//邮寄id
		function save(){
			var ligerForm = liger.get("ligerForm");
			 if (!ligerForm.valid()) {
			    	$.ligerDialog.SQalert({content:LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
		            return ; 
		     }
			var data = ligerForm.getData();
			
			data["arcAppId"] = '${arcBorrowMainVO.id}';//借阅申请id
			data["arcAppBussType"] = '${arcAppBussType}';//申请业务类型
			data["id"] = arcPostInfoId;//邮寄id
			
			
			//检查邮寄信息
			if($.trim($("#idCard").val()) == ""){
					alert("输入工号，点击'查找收件人'，查询出收件人（工号）和收件人（姓名）");
					return ;
			} 
			
		   if($.trim($("#sendType").val()) == ""){
				   alert("请选择接收方式");
				   return ;
			}
		   if($.trim($("#sendType").val()) == 0){
			   if($.trim($("#sendCompany").val()) == ""){
					$.ligerDialog.SQalert({content: "请选择快递公司",SQ_type: "warning",SQ_showButtons: true});
					return ;
				} 
			   if($.trim($("#sendNum").val()) == ""){
					$.ligerDialog.SQalert({content: "请输入快递单号",SQ_type: "warning",SQ_showButtons: true});
					return ;
				}
			   if($.trim($("#sendAddr").val()) == ""){
					$.ligerDialog.SQalert({content: "请输入邮寄地址",SQ_type: "warning",SQ_showButtons: true});
					return ;
				}
			}
		   
			console.log(data);
			
			var wait_dialog = null;
			$.ajax({
				type: 'post',
				dataType: 'json',
				data: data,
				url: '<%=path%>/archive/arcBorrowMain/arcPostInfoSave.do',
				beforeSend: function(){
					wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting"});
				},success:function(msg){
					wait_dialog.close();
					if(msg.success == 1){
							if(arcPostInfoId =="" && msg.data != "") arcPostInfoId = msg.data;
							alert(msg.info);
							//$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
							liger.get("gridPostInfo").reload();//刷新邮寄信息
					}else{
						$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					}
				},error:function (XMLHttpRequest, textStatus, errorThrown) { 
					wait_dialog.close();
					$.ligerDialog.SQalert({content: "网络错误，请稍后重试",SQ_type: "error"});
				} 
			});
		}
		
		function validatePhone(val){
		    var isPhone = /^([0-9]{3,4}-)?[0-9]{7,8}$/;//手机号码
		    var isMob= /^0?1[3|4|5|8][0-9]\d{8}$/;// 座机格式
		    if(isMob.test(val)||isPhone.test(val)){
		        return true;
		    }
		    else{
		        return false;
		    }
		}
		
		var arcPostInfoIdProvince = "${arcPostInfoVOProvince.id}";//邮寄id（省）
		var arcPostInfoIdZong = "${arcPostInfoVOZong.id}";//邮寄id（总）
		
		//总、省公司邮寄信息【归还】保存
		function saveReturn(arcAppBussType){
			
			//检查邮寄信息(省公司)
			if(arcAppBussType == 4) {
				if($.trim($("#idCardProvince").val()) == ""){
					alert("输入工号，点击'查找收件人'，查询出收件人（工号）和收件人（姓名）【省公司】");
						return ;
				} 
			   if($.trim($("#mobileProvince").val()) == ""){
					   alert("请填写联系电话【省公司】");
					   return ;
				} 
			   if(!validatePhone($("#mobileProvince").val())){
						alert("联系电话格式不对【省公司】");
						return ;
				}
			   if($.trim($("#sendTypeProvince").val()) == ""){
					   alert("请选择接收方式【省公司】");
					   return ;
				}
			   if($.trim($("#sendTypeProvince").val()) == 0){
				   if($.trim($("#sendCompanyProvince").val()) == ""){
						$.ligerDialog.SQalert({content: "请选择快递公司【省公司】",SQ_type: "warning",SQ_showButtons: true});
						return ;
					} 
				   if($.trim($("#sendNumProvince").val()) == ""){
						$.ligerDialog.SQalert({content: "请输入快递单号【省公司】",SQ_type: "warning",SQ_showButtons: true});
						return ;
					}
				   if($.trim($("#sendAddrProvince").val()) == ""){
						$.ligerDialog.SQalert({content: "请输入邮寄地址【省公司】",SQ_type: "warning",SQ_showButtons: true});
						return ;
					}
				}
			}else if(arcAppBussType == 5) {
				if($.trim($("#idCardZong").val()) == ""){
					alert("输入工号，点击'查找收件人'，查询出收件人（工号）和收件人（姓名）【总公司】");
						return ;
				} 
			   if($.trim($("#mobileZong").val()) == ""){
					   alert("请填写联系电话【总公司】");
					   return ;
				} 
			   if(!validatePhone($("#mobileZong").val())){
						alert("联系电话格式不对【总公司】");
						return ;
				}
			   if($.trim($("#sendTypeZong").val()) == ""){
					   alert("请选择接收方式【总公司】");
					   return ;
				}
			   if($.trim($("#sendTypeZong").val()) == 0){
				   if($.trim($("#sendCompanyZong").val()) == ""){
						$.ligerDialog.SQalert({content: "请选择快递公司【总公司】",SQ_type: "warning",SQ_showButtons: true});
						return ;
					} 
				   if($.trim($("#sendNumZong").val()) == ""){
						$.ligerDialog.SQalert({content: "请输入快递单号【总公司】",SQ_type: "warning",SQ_showButtons: true});
						return ;
					}
				   if($.trim($("#sendAddrZong").val()) == ""){
						$.ligerDialog.SQalert({content: "请输入邮寄地址【总公司】",SQ_type: "warning",SQ_showButtons: true});
						return ;
					}
				}
			   
			}
			
			var form ;
			if(arcAppBussType == 4) {//省公司
				form = "ligerFormProvince";
			}else {//总公司
				form = "ligerFormZong";
			}
			
			var data = $("#"+form).serialize();
			
			
			if(arcAppBussType == 4) {//省公司
				data+= '&id='+arcPostInfoIdProvince;//邮寄id
			}else {//总公司
				data+= '&id='+arcPostInfoIdZong;//邮寄id
			}
			data+= '&arcAppId=${id}';//借阅申请id 
			data+= '&arcAppBussType='+arcAppBussType;//申请业务类型
			
			
			console.log(data);
			
			var wait_dialog = null;
			$.ajax({
				type: 'post',
				dataType: 'json',
				data: data,
				url: '<%=path%>/archive/arcBorrowMain/arcPostInfoSave.do',
				beforeSend: function(){
					wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting"});
				},success:function(msg){
					wait_dialog.close();
					if(msg.success == 1){
							if(msg.data != "") {
								if(arcPostInfoIdProvince == "" && arcAppBussType == 4) {//省公司
									arcPostInfoIdProvince = msg.data;
								}else if(arcPostInfoIdZong == "" && arcAppBussType == 5) {//总公司
									arcPostInfoIdZong = msg.data;
								} 
							}
							alert(msg.info);
							//$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
							liger.get("gridPostInfo").reload();//刷新邮寄信息
					}else{
						$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					}
				},error:function (XMLHttpRequest, textStatus, errorThrown) { 
					wait_dialog.close();
					$.ligerDialog.SQalert({content: "网络错误，请稍后重试",SQ_type: "error"});
				} 
			});
		}
		
		function initGrid(){
			//1、初始化合同明细
			if(contractNo !="") {
				createGrid("gridContract",1);
			}
			
			//2、初始化权证资料明细
			<c:forEach items="${paySchNoList}" var="item">
				createGrid("gridPay${item}",2,"${item}");//创建ligerGrid
			</c:forEach>
			
			//3、初始化申请人邮寄信息
			createPostInfoGrid("gridProposerPostInfo","1","130");
			
			//4、初始化邮寄信息
			createPostInfoGrid("gridPostInfo","2;3;4;5","200");
			
			
		}
	     
		function createGrid(gridId,arcLevel,payListCode){
		     
			var _url = '<%=path%>/archive/arcBorrowMain/arcBorrowDetailList.do?arcBorrowMainId=${arcBorrowMainVO.id}&arcLevel='+arcLevel;
			if(payListCode) {
				_url += '&payListCode='+payListCode;
			}
			
			$("#"+gridId).ligerGrid({
				url:_url,
				method:'get',
				columns:[
					{ display: '权证类别', name: 'fileFlagNm',type:'text'},
					{ display: '权证名称', name: 'fileName',type:'text'},
					{display:'资料类型', name: 'dossierTempNm'},
					{display:'扫描件', name: 'arcMgrDetailVO.scanAttcheList', 
						 render: function (rowdata, rowindex, value) {
	                            var h = '<div class="gridNanoItems">';
	                            $(value).each(function(index, el) {
	                                h = h + '<div class="ellipsis"><a class="curPointer" href="javascript:downFile(';
	                                h+="'"+el.filePath+"'";
	                                h+=",'"+el.fileNm+"'";
	                                h+=')">'+el.fileNm+'</a></div>';
	                            });
	                            return h + '</div>';
	                        }
						},
					{display:'归档地点', name: 'arcMgrDetailVO.arcReceiptDetailVO.arcPlaceNm'},
					/* {display:'存档份数',name: 'arcMgrDetailVO.dossierCountT',type:'int'}, */
					{display:'是否归还/计划归还日期', 
						  render: function (item) {
			                    return item.originalReturnNm+" "+renderDate(null,null,item.returnDate);
			                }
					},
					{display:'归还状态', name: 'returnStateNm'},
					
					/* <c:if test="${from !='borrowerReturn'}"> 
					{display:'实际归还日期', 
						  render: function (item) {
			                    return renderDate(item.realReturnDate);
			                }
					},
					</c:if> */
					{ display: '实际归还日期', name: 'realReturnDate', render:renderDate,type: 'date',format: 'yyyy-MM-dd',editor: { type: 'date' } }
					
				],onBeforeSubmitEdit: function (e) {
		        
		        },
		        
		        enabledEdit: false,
			    //checkbox:true,//列表是否有选择框
				
				usePager: false,//是否有分页便签
				isScroll: true,//是否有滚动条
				root:'rows',
				record:'total',
				hideLoadButton:false,
				width:'100%',
				height:'200',
				heightDiff:-2,
				rownumbers:true,//列表是否有行号
				selectRowButtonOnly:true,//复选框模式时，是否只允许点击复选框才能选择行
				//选择行事件
				onSelectRow: function(rowdata, rowid, rowobj){
					
				},
				//取消选择行事件
				onUnSelectRow : function(rowdata, rowid, rowobj){
				},
				onBeforeCheckRow: function (checked, data, rowindex, rowobj) {
	            },
	            onAfterShowData: function () {
                    setNanoScroller();//设置附件列表每行高度
                }
			});
		}
		
		function createPostInfoGrid(gridId,arcAppBussTypes,_height){
		     
			$("#"+gridId).ligerGrid({
				url:'<%=path%>/archive/arcBorrowMain/arcPostInfoList.do?arcAppId=${arcBorrowMainVO.id}&arcAppBussTypes='+arcAppBussTypes,
				method:'get',
				columns:getColumns(gridId),
				onBeforeSubmitEdit: function (e) {
		        
		        },
			    enabledEdit: false,
				usePager: false,//是否有分页便签
				isScroll: true,//是否有滚动条
				root:'rows',
				record:'total',
				hideLoadButton:false,
				width:'100%',
				height:_height,
				fixedCellHeight: false,
				heightDiff:-2,
				//checkbox:true,//列表是否有选择框
				rownumbers:true,//列表是否有行号
				selectRowButtonOnly:true,//复选框模式时，是否只允许点击复选框才能选择行
				//选择行事件
				onSelectRow: function(rowdata, rowid, rowobj){
					
				},
				//取消选择行事件
				onUnSelectRow : function(rowdata, rowid, rowobj){
				},
				onBeforeCheckRow: function (checked, data, rowindex, rowobj) {
	            }
			});
		}
		
		function getColumns(gridId){
			var col_data = [
							{ display: '地址类型', name: 'arcAppBussTypeNm',type:'text'},
							{ display: '收件人（工号）', name: 'idCard',type:'text'},
							{ display: '收件人（姓名）', name: 'recipient',type:'text'},
							{ display: '联系电话', name: 'mobile',type:'text'},
							{ display: '邮寄方式', name: 'sendTypeNm',type:'text'},
							{ display: '地址', name: 'sendAddr',type:'text',isEllipsis: false}
							
						];
			if(gridId =="gridProposerPostInfo") {
				col_data.push({ display: '借阅类型', name: 'borrowTypeNm',type:'text'});
				col_data.push({ display: '借阅用途', name: 'borrowUseNm',type:'text',isEllipsis: false});
				col_data.push({ display: '借阅备注', name: 'borrowRemark',type:'text',isEllipsis: false});
			}else {
				col_data.push({ display: '物流公司', name: 'sendCompanyNm',type:'text'});
				col_data.push({ display: '快递单号', name: 'sendNum',type:'text'});
			}
			
			return col_data;
		}
		
		function renderDate(rowdata, index, value){
			var dateStr = "";
			if(value != null && value !=""){
				var date = new Date(value);
				dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
			}
			return dateStr;
		}	
		
		function setBorrowUse(obj){
			if(obj.value == "") {
				liger.get("borrowUse").clear();
				liger.get("borrowUse").setData({});
			}else {
				 $.ajax({
					type: 'post',
					dataType:'json',
					data:{code:obj.value},
					url: '<%=path%>/archive/arcBorrowMain/getBorrowUse.do',
					success:function(msg){
						 if(msg.success == 1){
							 var borrowUse = liger.get("borrowUse");
							 if(msg.data){
								 borrowUse.setData(msg.data);
							 }else{
								 borrowUse.clear();
								 borrowUse.setData({});//置空下拉框数据
							 }
						 }else{
							 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
						 }
					}
				}); 
			}
		}
		
		function getSysUsr(jobNum,idCard,recipient,mobile){
			
			var jobNum = $.trim($("#"+jobNum).val());
			if( jobNum == ""){
				$.ligerDialog.SQalert({content: "请填写工号",SQ_type: "warning"});
				return;
			}
			
			 $.ajax({
				type: 'get',
				dataType:'json',
				url: '<%=path%>/archive/arcBorrowMain/getSysUsr.do?jobNum='+jobNum,
				success:function(msg){
					console.log(msg);
					 if(msg.success == 1){
						 if(msg.data){
							 $("#"+idCard).val(msg.data.usrNm);
							 $("#"+recipient).val(msg.data.refRlNm);
							 $("#"+mobile).val(msg.data.mp);
						 }else{
							 $.ligerDialog.SQalert({content:"没有查询到对应人员", SQ_type: "warning"});
						 }
					 }else{
						 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			}); 
		}
		
		//设置附件列表每行高度
		 function setNanoScroller () {
	         $('.gridNanoItems').each(function(index, el) {
	             if ($(el).height() > 100 ) {
	            	 $(el).wrap('<div class="gridNanoContainer"><div class="nano"><div class="nano-content">');
	                 $(el).parents('.gridNanoContainer').height(100);
	                 $(".nano").nanoScroller({
	                     preventPageScrolling: true
	                 });
	             };
	         });
	     }
		//下载文件
		function downFile(_url,_name){
			if(SQ.regs.img.test(_name)){
				SQ.imgPreview(_url, true);
			}else{
				window.open(_url);
			}
		}
		
		
		 //上传回调方法
	    function uploadCallbackForMore(_data){
	     	var _businessKey = '${arcBorrowMainVO.id}';
	     	var _attchmnt = JSON.stringify(_data);//附件的集合
	    	
	    	var params = {
	     			businessKey:_businessKey,
	     			attchmnt:_attchmnt
	    		}
	     	
	    	var _url = '<%=path%>/archive/arcBorrowMain/saveUploadRecord.do';
			AjaxUtils.ajaxPost(_url, params, function(msg){
				if(msg.success == 1){
					refreshUlFileRecListByPkId(_businessKey,"ARC_BORROW_MAIN");
	   			 }else{
	   				UIUtils.alertError(msg.info);
	   			 }
	   	    },true);
	    }
	</script>
</body>
</html>